package com.klhappy.houyuan.utils.headshot;

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Environment;
import android.util.Log;

import com.klhappy.houyuan.constant.KeyConstant;

import java.io.File;

public class HeadShotUtil {

    public static Bitmap getHeadShot(String imgName) {
        Bitmap bitmap = null;
        String seperator = File.separator;
        String path = Environment.getExternalStorageDirectory() + seperator + KeyConstant.APP_DIR +
                seperator + KeyConstant.IMAGE_DIR + seperator + KeyConstant.HEAD_SHOT
                + seperator + imgName;
        File headImage = new File(path);
        if (!headImage.exists()) {
            Log.d("mao", headImage.getAbsolutePath());
            Log.d("mao", "文件不存在");
        } else {
            try {
                bitmap = BitmapFactory.decodeFile(headImage.getAbsolutePath());
            } catch (Exception e) {
                Log.d("mao", "BitmapFactory error");
                Log.d("mao", e.getMessage());
                e.printStackTrace();
            }
        }
        return bitmap;
    }

}
